
package com.example.cia.database.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.example.cia.database.mysql.dao.impl.addDeviceImpl;

public class modifyDeviceServlet extends HttpServlet{

	/**
	 * 修改设备状态的servlet
	 */
	private static final long serialVersionUID = -8013299251454399766L;

	public void doGet(HttpServletRequest request,HttpServletResponse response)
		throws ServletException,IOException{
		int result;
		
		//获取更新信息
		String id = request.getParameter("id");
		int state = Integer.parseInt(request.getParameter("state"));
		
		//获取更新操作对象
		addDeviceImpl adi = new addDeviceImpl();
		
		//执行更新操作
		try {
			result = adi.modify(id, state);
			response.setCharacterEncoding("UTF-8");
			response.setContentType("text/html");
			PrintWriter out = response.getWriter();
			out.print((result!=0));
			out.flush();
			out.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public void doPost(HttpServletRequest request,HttpServletResponse response)
		throws ServletException,IOException{
		
	}
}
